package com.gzrhhscd.config;

import com.gzrhhscd.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
        registry.addInterceptor(loginCheckInterceptor).excludePathPatterns("/**");
    }
   //@Override
//    public void addCorsMappings(CorsRegistry registry) {
//        // 添加CORS映射路径和允许的请求方法
//        registry.addMapping("/**")
//                .allowedMethods("RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE")
//                .allowedOrigins("*") // 允许来自任何源的请求
//                .allowedHeaders("*") // 允许任何头部信息
//                .maxAge(3600); // 预检请求的有效期为3600秒
//    }




}
